#include <cstdio>
#include <cstring>
#include <queue>

const int N = 100005;
int n, cnt, top, ch[N][26], fail[N], key[N], ans[N], lst[N];
char str[N], S[N];

inline void insert(char *s) {
  int cur = 0, c, m = strlen(s);
  while (*s) {
    c = *s - 'a';
    if (!ch[cur][c]) ch[cur][c] = ++cnt;
    cur = ch[cur][c];
    s++;
  }
  key[cur] = m;
}

inline void getfail() {
  std::queue<int> q;
  for (int i = 0; i < 26; ++i)
    if (ch[0][i]) q.push(ch[0][i]);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0, v; i < 26; ++i) {
      if ((v = ch[u][i]))
        q.push(v), fail[v] = ch[fail[u]][i];
      else
        ch[u][i] = ch[fail[u]][i];
    }
  }
}

inline void solve() {
  int cur = 0, c, m = strlen(S);
  for (int i = 0; i < m; ++i) {
    c = S[i] - 'a';
    lst[i] = cur = ch[cur][c];
    ans[++top] = i;
    if (key[cur]) {
      top -= key[cur];
      cur = lst[ans[top]];
    }
  }
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("CppTest.in", "r", stdin);
  freopen("CppTest.out", "w", stdout);
#endif
#endif

  scanf("%s", S);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", str);
    insert(str);
  }
  getfail();
  solve();
  for (int i = 1; i <= top; ++i) {
    putchar(S[ans[i]]);
  }
  return 0;
}